﻿using System;
using System.Text;
using IAM.Interface.Model;
using IAM.Interface.Model.ENUM;
using IAM.Interface.Common.Context;
using IAM.Interface.DAL.Request.Interface;
using IAM.Interface.IDAL;

namespace IAM.Interface.DAL.Request
{
    /// <summary>
    /// 组织信息管理
    /// </summary>
    public class OrganizationMgnt : AbstractAppType, IOrganizationMgnt
    {
        #region 方法
        /// <summary>
        /// 组织信息更新
        /// </summary>
        /// <param name="organizeinfo">组织机构信息,包括机构基本信息和主管人员信息</param>
        /// <returns>成功/失败</returns>
        public bool UpdateOrganize(OrganizeInfo organizeinfo)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.ORG_UPDATE,
                OperationType.Nullity,
                organizeinfo,
                organizeinfo.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            if (((ResponseData)obj).StatusCode == 200)
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        /// <summary>
        /// 组织机构创立
        /// </summary>
        /// <param name="organizeinfo">组织机构信息,包括机构基本信息和主管人员信息</param>
        /// <returns>成功/失败</returns>
        public bool CreateOrganize(OrganizeInfo organizeinfo)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.ORG_CREATE,
                OperationType.Nullity,
                organizeinfo,
                organizeinfo.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            if (((ResponseData)obj).StatusCode == 200)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 组织结构删除（包括合并）
        /// </summary>
        /// <param name="organizedeleteparameter">组织结构删除 组织机构信息</param>
        /// <returns>成功/失败</returns>
        public bool DeleteOrganize(OrganizeDeleteParameter organizedeleteparameter)
        {
            //1.实例化RequestContextModel对象
            RequestContextModel rcm = new RequestContextModel(
                ActionType.ORG_DELETE,
                OperationType.Nullity,
                organizedeleteparameter,
                organizedeleteparameter.GetType(),
                AppType);
            //2.实例化请求端上下文控制对象
            RequestContextControl rcc = new RequestContextControl(rcm);
            //3.发送消息
            string strreturn = rcc.Send();
            //4.接收消息
            object obj = rcc.Incept(strreturn);
            //5.转换通用类的类型
            if (((ResponseData)obj).StatusCode == 200)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion
    }
}
